//
//  CommentModel.m
//  Connotation
//
//  Created by 黄世光 on 15/8/18.
//  Copyright (c) 2015年 LZXuan. All rights reserved.
//

#import "CommentModel.h"

@implementation CommentModel
-(void)dealloc{
    self.author_avatar=nil;
    self.author_name=nil;
    self.content=nil;
    self.created_time=nil;
    self.page_size=nil;
    self.total=nil;
    [super dealloc];
}
-(void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:self.author_avatar forKey:@"author_avatar"];
    [aCoder encodeObject:self.author_name forKey:@"author_name"];
    [aCoder encodeObject:self.content  forKey:@"content"];
    [aCoder encodeObject:self.created_time  forKey:@"created_time"];
    [aCoder encodeObject:self.page_size forKey:@"page_size"];
    [aCoder encodeObject:self.total forKey:@"total"];
}
-(id)initWithCoder:(NSCoder *)aDecoder{
    if(self=[super init]) {
        //这里不要直接写 成员变量 否则就有可能崩溃
        //要用setter方法 这样内部会计数器+1 拥有绝对使用权
        self.author_avatar=[aDecoder decodeObjectForKey:@"author_avatar"];
        self.author_name=[aDecoder decodeObjectForKey:@"author_name"];
        //要注意拥有绝对使用权
        self.content=[[aDecoder decodeObjectForKey:@"content"]retain];
        self.created_time=[[aDecoder decodeObjectForKey:@"created_time"]retain];
        self.page_size=[aDecoder decodeObjectForKey:@"page_size"];
        self.total=[aDecoder decodeObjectForKey:@"total"];
    }
    return self;
}

@end
